package ch06;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class Test {
    private static ApplicationContext applicationContext ;
    static {
        applicationContext = new ClassPathXmlApplicationContext("ch06/spring.xml") ;
    }

    public void test1(){
        Person person = (Person) applicationContext.getBean("person3") ;
        person.show();
    }

    public static void test2(){
        BigClass bigClass = (BigClass) applicationContext.getBean("bigClass") ;
        System.out.println(bigClass.getId() + "----" + bigClass.getAddress());
        System.out.println("=======================");
        System.out.println(bigClass.getPerson().getName() + "----"+bigClass.getPerson().getWords());
        System.out.println("=======================");
        String[] strings = bigClass.getStrings() ;
        for(String s :strings){
            System.out.println(s);
        }
        System.out.println("==========================");
        List<String> list = bigClass.getList() ;
        for(String s : list){
            System.out.println(s);
        }
        System.out.println("===========================");
        Set<String> set = bigClass.getSet() ;
        for(String s : set){
            System.out.println(s);
        }
        System.out.println("==============================");
        Map<String,Object> map = bigClass.getMap() ;
        for(Map.Entry<String,Object> entry : map.entrySet()){
            System.out.println(entry.getKey() + "---" + entry.getValue());
        }
        System.out.println("=============================");
        Properties properties = bigClass.getProperties() ;
        for(Map.Entry entry : properties.entrySet()){
            System.out.println(entry.getKey() + "---" + entry.getValue());
        }
    }

    public void test3(){
        PersonDao personDao = (PersonDao) applicationContext.getBean("personDao") ;
       // personDao.savePerson(new Person()) ;
        personDao.del();
    }

    public static void main(String[] args) {
        Test test = new Test() ;
        test.test3();
    }
}
